package com.cskaoyan;

//import com.mysql.jdbc.Driver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2021/11/23 10:52
 * 增加的Demo
 * @author ciggar
 */
public class JDBCDemo2 {

    public static void main(String[] args) throws SQLException {

        // 1. 注册驱动
//        DriverManager.registerDriver(new Driver());


        // 2. 获取连接  返回的是Connection接口的实现类
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/36th_rev?useSSL=false","root","123456");

        // 3. 获取statement对象 这个对象是用来包装SQL语句为网络请求
        Statement statement = connection.createStatement();

        // 4. 通过statement对象发送SQL语句
        int affectedRows = statement.executeUpdate("insert into student values (12,'佟丽娅','三班',120)");

        // 5. 解析结果集
        System.out.println("affectedRows:" + affectedRows);

        // 6. 关闭资源
        statement.close();
        connection.close();

    }
}
